


#ifndef XPM_H
#define XPM_H


class XPM {
	int id;	
	int height;
	int width;
	int nColours;
	char *data;
	char codeTransparent;
	char *codes;
	ColourPair *colours;
	ColourAllocated ColourFromCode(int ch);
	void FillRun(Surface *surface, int code, int startX, int y, int x);
	char **lines;
	ColourPair *colourCodeTable[256];
public:
	XPM(const char *textForm);
	XPM(const char * const *linesForm);
	~XPM();
	void Init(const char *textForm);
	void Init(const char * const *linesForm);
	void Clear();

	void RefreshColourPalette(Palette &pal, bool want);

	void CopyDesiredColours();

	void Draw(Surface *surface, PRectangle &rc);
	char **InLinesForm() { return lines; }
	void SetId(int id_) { id = id_; }
	int GetId() { return id; }
	int GetHeight() { return height; }
	int GetWidth() { return width; }
	static const char **LinesFormFromTextForm(const char *textForm);
};


class XPMSet {
	XPM **set;
	int len;
	int maximum;
	int height;
	int width;
public:
	XPMSet();
	~XPMSet();

	void Clear();

	void Add(int id, const char *textForm);

	XPM *Get(int id);

	int GetHeight();

	int GetWidth();
};

#endif
